package com.sikadwafastdaisfondturbo.pretloan.app

import android.app.Activity
import android.app.Application
import android.os.Bundle
import com.sikadwafastdaisfondturbo.pretloan.utils.helper.ActivityStackHelper
import com.sikadwafastdaisfondturbo.pretloan.utils.helper.ForegroundBackgroundHelper
import com.sikadwafastdaisfondturbo.pretloan.utils.log.HHLog

/**
 * @Author：apple
 * @Time：2024/4/14 15:47
 * @Description：Activity生命周期监听
 */
class ActivityLifecycleCallbacksImpl : Application.ActivityLifecycleCallbacks {

    override fun onActivityCreated(activity: Activity, bundle: Bundle?) {
        ActivityStackHelper.addActivityToStack(activity)
        HHLog.e("${activity.javaClass.simpleName} --> onActivityCreated")
    }

    override fun onActivityStarted(activity: Activity) {
        HHLog.e("${activity.javaClass.simpleName} --> onActivityStarted")
        ForegroundBackgroundHelper.onActivityStarted()
    }

    override fun onActivityResumed(activity: Activity) {
        HHLog.e("${activity.javaClass.simpleName} --> onActivityResumed")
    }

    override fun onActivityPaused(activity: Activity) {
        HHLog.e("${activity.javaClass.simpleName} --> onActivityPaused")
    }

    override fun onActivityStopped(activity: Activity) {
        HHLog.e("${activity.javaClass.simpleName} --> onActivityStopped")
        ForegroundBackgroundHelper.onActivityStopped()
    }

    override fun onActivitySaveInstanceState(activity: Activity, outState: Bundle) {
        HHLog.e("${activity.javaClass.simpleName} --> onActivitySaveInstanceState")
    }

    override fun onActivityDestroyed(activity: Activity) {
        ActivityStackHelper.popActivityToStack(activity)
        HHLog.e("${activity.javaClass.simpleName} --> onActivityDestroyed")
    }
}